<?php defined('SYSPATH') OR die('No direct access allowed.');

class Content_Controller extends Viewbase_Controller{
	
	public function __construct(){
		$this->modelname='content';	
		$this->controllername='content';
		$this->orderby=array('lang'=>'','container'=>'', 'position'=>'');
		$this->forms=array(array('title'=>'Input', 'link'=>'input'),array('title'=>'Action', 'link'=>'action'));
		$this->parent_column='page_id';		
		parent::__construct();
		$this->template->head=new View('langselect');
	}
	
	public function __preprocess_post($model){
		if($model->id=='0'){
			$model->created_by=$this->auth->get_user()->id;
		}else{
			$model->modified_by=$this->auth->get_user()->id;
		}
		eval($model->contentmodule->preprocess_post);
		return ($model);	
	}
	public function __postprocess_model($model){
		$model->reload();
		eval($model->contentmodule->postprocess_model);
		$model->save();
		$model->shortname=inflector::underscore($model->title).'_'.$model->id;
		$model->save();	
	}
	
	public function get_parent_column_name($model=NULL){
		if($model->parent_col!=''){
			return $model->parent_col;
		}
		return $this->parent_column;
	}
}